const GenerateAssetPlugin = require('generate-asset-webpack-plugin');
const {name: APP_NAME} = require('./package.json');

const createServerConfig = function () {
    // const configJson = {ApiUrl: "http://115.239.175.246:5305/"};//线上
    // const configJson = {ApiUrl: "http://10.10.10.3:8080/"};
    // const configJson = {ApiUrl: "http://10.10.10.35:8081/czfwpt/"};
    const configJson = {ApiUrl: "http://10.10.10.35:8081/czfwptbackend/"};
    // const configJson = {ApiUrl: "http://10.10.10.158:8084/"};//傅
    // const configJson = {ApiUrl: "http://10.10.10.145:8084/"};//郑
    // const configJson = {
    //     ApiUrl: "http://115.239.175.246:5101/czfwpt/"
    // }; //35服务器
    // const configJson = {ApiUrl: "http://115.239.175.246:5301/zjczfwpt/"}; //徐弘扬
    return JSON.stringify(configJson);
}


module.exports = {
    lintOnSave: false,
    publicPath: `/${APP_NAME}/`,
    outputDir: APP_NAME,
    css: {
        loaderOptions: {
            less: {
                javascriptEnabled: true,
            }
        }
    },
    devServer: {
        port: 8080,
        https: false,
        hotOnly: false,
        disableHostCheck: true,
        open: true
    },
    configureWebpack: {
        plugins: [
            new GenerateAssetPlugin({
                filename: 'serverConfig.json',
                fn: (compilation, cb) => {
                    cb(null, createServerConfig());
                },
            })
        ]
    }
}
